package com.eva.cms.databuilder.builders.cms;

import com.eva.cms.biz.category.CmsCategoryBiz;
import com.eva.cms.biz.category.vo.CmsCategoryNodeVO;
import com.eva.cms.databuilder.AbstractTemplateDataBuilder;
import com.eva.cms.databuilder.bo.TemplateDataParameters;
import com.eva.framework.cache.autowired.Cache;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 构建栏目树数据
 */
@Slf4j
@Component
public class CategoryTreeBuilder extends AbstractTemplateDataBuilder<List<CmsCategoryNodeVO>> {

    @Resource
    private CmsCategoryBiz cmsCategoryBiz;

    // 永久缓存，后台操作栏目时会清理此缓存
    @Cache("CATEGORIES_TREE")
    public List<CmsCategoryNodeVO> build(TemplateDataParameters parameters) {
        // v1.3.0调整，统一查询栏目树方法
        return cmsCategoryBiz.findTree(Boolean.FALSE, parameters);
    }
}
